<?php
/**
 * 演示继承
 *
 * User: ford
 * Date: 15-6-17
 * Time: 上午10:29
 */

class Employee {
	protected $name;
	protected $salary;

	function __construct($name, $salary = 100) {
		$this->name = $name;
		$this->salary = $salary;
	}

	function giveRaise($amount) {
		$this->salary += $amount;
		echo "Employee $this->name got raise of $amount dollars <br />";
		echo "New Salary is $this->salary 。<br />";
	}

	function __destruct() {
		echo "Good bye, cruel world: EMPLOYEE: $this->name .<br />";
	}

}

class Manager extends Employee {
	protected $dept;

	function __contruct($name, $salary, $dept) {
		parent::__construct($name, $salary);
		$this->dept = $dept;
	}

	function giveRaise($amount) {
		parent::giveRaise($amount);
		echo "This employee is a manager. <br />";
	}

	function __destruct() {
		echo "Good bye, cruel world: MANAGER: " . $this->name . '<br />';
		parent::__destruct();
	}
}

$mgr = new Manager('Smith', 300, 20);
$mgr->giveRaise(50);

$emp = new Employee('Johnson', 100);
$emp->giveRaise(50);